﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DatabaseCore;
using ExportSystem.Master;
using WeifenLuo.WinFormsUI.Docking;

namespace ExportSystem.Order
{
    public class OrderForm : DockContent
    {
        private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
        private System.Windows.Forms.Button buttonOrderSave;
        private System.Windows.Forms.DataGridView dataGridViewOrder;
        private System.Windows.Forms.DataGridViewCheckBoxColumn IsSelected;
        private System.Windows.Forms.DataGridViewTextBoxColumn OrderNo;
        private System.Windows.Forms.Button buttonImportOrder;
        private System.Windows.Forms.Button ButtonOrderCancel;
        public OrderForm()
        {
            InitializeComponent();
        }
        public OrderForm(List<tbl_Order> orderData){
            InitializeComponent();
            dataGridViewOrder.DataSource = orderData;
        }
        private void InitializeComponent()
        {
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.dataGridViewOrder = new System.Windows.Forms.DataGridView();
            this.buttonOrderSave = new System.Windows.Forms.Button();
            this.ButtonOrderCancel = new System.Windows.Forms.Button();
            this.IsSelected = new System.Windows.Forms.DataGridViewCheckBoxColumn();
            this.OrderNo = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.buttonImportOrder = new System.Windows.Forms.Button();
            this.tableLayoutPanel1.SuspendLayout();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewOrder)).BeginInit();
            this.SuspendLayout();
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.ColumnCount = 3;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
            this.tableLayoutPanel1.Controls.Add(this.dataGridViewOrder, 0, 0);
            this.tableLayoutPanel1.Controls.Add(this.ButtonOrderCancel, 2, 1);
            this.tableLayoutPanel1.Controls.Add(this.buttonOrderSave, 1, 1);
            this.tableLayoutPanel1.Controls.Add(this.buttonImportOrder, 0, 1);
            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
            this.tableLayoutPanel1.Margin = new System.Windows.Forms.Padding(8);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 2;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
            this.tableLayoutPanel1.Size = new System.Drawing.Size(681, 407);
            this.tableLayoutPanel1.TabIndex = 0;
            // 
            // dataGridViewOrder
            // 
            this.dataGridViewOrder.AllowUserToOrderColumns = true;
            this.dataGridViewOrder.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridViewOrder.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.IsSelected,
            this.OrderNo});
            this.tableLayoutPanel1.SetColumnSpan(this.dataGridViewOrder, 3);
            this.dataGridViewOrder.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dataGridViewOrder.Location = new System.Drawing.Point(3, 3);
            this.dataGridViewOrder.Name = "dataGridViewOrder";
            this.dataGridViewOrder.Size = new System.Drawing.Size(675, 362);
            this.dataGridViewOrder.TabIndex = 0;
            // 
            // buttonOrderSave
            // 
            this.buttonOrderSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.buttonOrderSave.Location = new System.Drawing.Point(515, 376);
            this.buttonOrderSave.Margin = new System.Windows.Forms.Padding(8, 8, 4, 8);
            this.buttonOrderSave.Name = "buttonOrderSave";
            this.buttonOrderSave.Size = new System.Drawing.Size(75, 23);
            this.buttonOrderSave.TabIndex = 2;
            this.buttonOrderSave.Text = "Save";
            this.buttonOrderSave.UseVisualStyleBackColor = true;
            this.buttonOrderSave.Click += new System.EventHandler(this.buttonOrderSave_Click);
            // 
            // ButtonOrderCancel
            // 
            this.ButtonOrderCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
            this.ButtonOrderCancel.Location = new System.Drawing.Point(598, 376);
            this.ButtonOrderCancel.Margin = new System.Windows.Forms.Padding(4, 8, 8, 8);
            this.ButtonOrderCancel.Name = "ButtonOrderCancel";
            this.ButtonOrderCancel.Size = new System.Drawing.Size(75, 23);
            this.ButtonOrderCancel.TabIndex = 3;
            this.ButtonOrderCancel.Text = "Cancel";
            this.ButtonOrderCancel.UseVisualStyleBackColor = true;
            // 
            // IsSelected
            // 
            this.IsSelected.HeaderText = "เลือก";
            this.IsSelected.Name = "IsSelected";
            // 
            // OrderNo
            // 
            this.OrderNo.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
            this.OrderNo.DataPropertyName = "OrderNo";
            this.OrderNo.HeaderText = "เลขที่ใบสั่งซื้อ";
            this.OrderNo.Name = "OrderNo";
            // 
            // buttonImportOrder
            // 
            this.buttonImportOrder.Location = new System.Drawing.Point(8, 376);
            this.buttonImportOrder.Margin = new System.Windows.Forms.Padding(8);
            this.buttonImportOrder.Name = "buttonImportOrder";
            this.buttonImportOrder.Size = new System.Drawing.Size(75, 23);
            this.buttonImportOrder.TabIndex = 4;
            this.buttonImportOrder.Text = "Import Order";
            this.buttonImportOrder.UseVisualStyleBackColor = true;
            this.buttonImportOrder.Click += new System.EventHandler(this.buttonImportOrder_Click);
            // 
            // OrderForm
            // 
            this.ClientSize = new System.Drawing.Size(681, 407);
            this.Controls.Add(this.tableLayoutPanel1);
            this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
            this.Name = "OrderForm";
            this.Text = "Order Management";
            this.tableLayoutPanel1.ResumeLayout(false);
            ((System.ComponentModel.ISupportInitialize)(this.dataGridViewOrder)).EndInit();
            this.ResumeLayout(false);

        }

        private void buttonOrderSave_Click(object sender, EventArgs e)
        {
            var result = dataGridViewOrder.DataSource;
        }

        private void buttonImportOrder_Click(object sender, EventArgs e)
        {
            var importForm = new ImportForm();
            importForm.ShowDialog();
            var k = new OrderDetailsForm();
            
            var orderDetails = new List<tbl_OrderDetail>();
            orderDetails.Add(new tbl_OrderDetail { OrderNo = "1" });
            orderDetails.Add(new tbl_OrderDetail { OrderNo = "2" });
            k.DataSource = orderDetails;
            k.BindingDataSource();
            k.ShowDialog();
        }
    }
}
